#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main()
{
	int a, b;
	int digit = 0;
	scanf("%d%d", &a, &b);
	for (int i = a; i <= b; i++) {
		for (int q=i; q > 0; q /= 10) {
			if (q % 10 == 2)
				digit++;
		}
	}
	printf("%d", digit);
	return 0;
}